package br.com.toscano.contpedido.view;

import javax.inject.Inject;
import br.gov.frameworkdemoiselle.annotation.PreviousView;
import br.gov.frameworkdemoiselle.stereotype.ViewController;
import br.gov.frameworkdemoiselle.template.AbstractEditPageBean;
import br.gov.frameworkdemoiselle.transaction.Transactional;
import br.com.toscano.contpedido.business.LocalProducaoBC;
import br.com.toscano.contpedido.domain.LocalProducao;

@ViewController
@PreviousView("./localProducao_list.jsf")
public class LocalProducaoEditMB extends AbstractEditPageBean<LocalProducao, Long> {

	private static final long serialVersionUID = 1L;

	@Inject
	private LocalProducaoBC localProducaoBC;
	
	@Override
	@Transactional
	public String delete() {
		this.localProducaoBC.delete(getId());
		return getPreviousView();
	}
	
	@Override
	@Transactional
	public String insert() {
		this.localProducaoBC.insert(getBean());
		return getPreviousView();
	}
	
	@Override
	@Transactional
	public String update() {
		this.localProducaoBC.update(getBean());
		return getPreviousView();
	}
	
	@Override
	protected LocalProducao handleLoad(Long id ) {
		setBean(this.localProducaoBC.load(id));
		
		return this.getBean();
	}

}